<template>
  <div>
    <div style="padding: 5px 10px">
      <h3>审批信息:</h3>
      <process-handle-history :business-key="businessKey" :process-key="processKey"/>
    </div>
    <div style="padding: 5px 10px">
      <h3>会审信息:</h3>
      <div v-for="(item,index) in opinionDetailList" :key="index" v-if="opinionDetailList.length!=0">
        <table class="bs-table">
        <tr class="bs-table_row" style="width: 100%;">
          <th class="bs-table_th" width="200px">会审标题</th>
          <td class="bs-table_td" colspan="5">{{item.title}}</td>
        </tr>
        <tr class="bs-table_row">
          <th class="bs-table_th">相关说明</th>
          <td class="bs-table_td" colspan="5">{{item.content}}</td>
        </tr>
        <tr class="bs-table_row">
          <th class="bs-table_th">发起部门</th>
          <td class="bs-table_td"  colspan="3">{{item.deptName}}</td>
          <th class="bs-table_th" width="200px">发起时间</th>
          <td class="bs-table_td"  colspan="2">{{item.createTime}}</td>
        </tr>
        <tr class="bs-table_row">
          <th class="bs-table_th">相关附件</th>
          <td class="bs-table_td" colspan="5">
            <div v-for="fileid in item.fileIds" :key="fileid">
              <preview :attachementId="Number(fileid)" v-if="fileid"></preview>
            </div>
          </td>
        </tr>
        </table>

      <table class="bs-table" style="margin-bottom: 30px">
        <tr class="bs-table_row">
          <th class="bs-table_th" width="200px">反馈部门</th>
          <th class="bs-table_th" width="80px">状态</th>
          <th class="bs-table_th" width="160px">反馈时间</th>
          <th class="bs-table_th" width="60px">有无意见</th>
          <th class="bs-table_th">意见</th>
          <th class="bs-table_th">附件</th>

        </tr>
        <tr class="bs-table_row"  v-for="(record,index) in item.targetDetailList" :key="index">
          <th class="bs-table_td">{{record.deptName}}</th>
          <th class="bs-table_td">{{OPINIONDIC.state[record.state]}}</th>
          <th class="bs-table_td">{{record.feedbackTime}}</th>
          <th class="bs-table_td" v-if="record.formList.length">{{HASOPINIONDIC[record.formList[0].fieldMap.hasOpinion]}}</th><th class="bs-table_td" v-else></th>
          <th class="bs-table_td" v-if="record.formList.length">{{record.formList[0].fieldMap.opinion}}</th><th class="bs-table_td" v-else></th>
          <th class="bs-table_td" v-if="record.formList.length">
            <div v-for="fileid in record.formList[0].fileIds" :key="fileid" v-if="record.formList[0].fileIds.length!=0">
              <preview :attachementId="Number(fileid)" v-if="fileid"></preview>
            </div>
          </th><th class="bs-table_td" v-else></th>
        </tr>
      </table>
      </div>
      <div v-if="opinionDetailList.length==0" style="text-align: center;font-size: 18px;color: #3333;height: 160px;line-height: 160px;">
        暂无数据
      </div>
    </div>
    <div style="padding: 5px 10px">
      <h3>衔接信息:</h3>
      <div v-for="(item,index) in connectDetailList" :key="index" v-if="connectDetailList.length!=0">
        <table class="bs-table" style="margin-bottom: 40px">
          <tr class="bs-table_row" style="width: 100%;">
            <th class="bs-table_th" width="200px">衔接主题</th>
            <td class="bs-table_td" colspan="5">{{item.title}}</td>
          </tr>
          <tr class="bs-table_row">
            <th class="bs-table_th">衔接说明</th>
            <td class="bs-table_td" colspan="5">{{item.content}}</td>
          </tr>
          <tr class="bs-table_row">
            <th class="bs-table_th">发起部门</th>
            <td class="bs-table_td" colspan="3">{{item.deptName}}</td>
            <th class="bs-table_th" width="200px">发起时间</th>
            <td class="bs-table_td" colspan="2">{{item.createTime}}</td>
          </tr>
          <tr class="bs-table_row">
            <th class="bs-table_th">衔接请示件</th>
            <td class="bs-table_td" colspan="5">
              <div v-for="(fileid,index) in item.fileIds" :key="index">
                <preview :attachementId="Number(fileid)" v-if="fileid"></preview>
              </div>
            </td>
          </tr>
          <tr class="bs-table_row">
            <th class="bs-table_th" width="200px">反馈部门</th>
            <th class="bs-table_th" width="80px">状态</th>
            <th class="bs-table_th" width="160px">反馈时间</th>
            <th class="bs-table_th" width="60px">有无意见</th>
            <th class="bs-table_th">意见</th>
            <th class="bs-table_th">附件</th>

          </tr>
          <tr class="bs-table_row"  v-for="(record, index) in item.targetDetailList" :key="index">
            <th class="bs-table_td">{{record.deptName}}</th>
            <th class="bs-table_td">{{OPINIONDIC.state[record.state]}}</th>
            <th class="bs-table_td">{{record.feedbackTime}}</th>
            <th class="bs-table_td" v-if="record.formList.length">{{HASOPINIONDIC[record.formList[0].fieldMap.hasOpinion]}}</th><th class="bs-table_td" v-else></th>
            <th class="bs-table_td" v-if="record.formList.length">{{record.formList[0].fieldMap.opinion}}</th><th class="bs-table_td" v-else></th>
            <th class="bs-table_td" v-if="record.formList.length">
              <div v-for="fileid in record.formList[0].fileIds" :key="fileid" v-if="record.formList[0].fileIds.length!=0">
                <preview :attachementId="Number(fileid)" v-if="fileid"></preview>
              </div>
            </th><th class="bs-table_td" v-else></th>
          </tr>

        </table>
      </div>
      <div v-if="connectDetailList.length==0" style="text-align: center;font-size: 18px;color: #3333;height: 160px;line-height: 160px;">
        暂无数据
      </div>
    </div>
    <assign-history :visible="assignHisVisible"
                    :taskAssigneeHisList="taskAssigneeHisList"
                    @cancelAssignHis="cancelAssignHis"></assign-history>
  </div>
</template>

<script>
  import {getReviewDetail} from "@/api/achievement";
  import {OPINIONDIC} from "@/const/opinion";
  import processHandleHistory from "@/components/activiti/history/processHandleHistory";

  export default {
    name: "reviewDetailPage",
    components:{
      processHandleHistory
    },
    data() {
      return {
        detaildata:{},
        opinionDetailList:[],
        connectDetailList:[],
        OPINIONDIC:OPINIONDIC,
        HASOPINIONDIC:{
          'true': "有",
          'false': "无",
        },
        assignHisVisible:false,
        taskAssigneeHisList:[],
        myhisList:[],
        businessKey: null,
        processKey: 'planning-review'
      }
    },
    props: {
      id: Number
    },
    created() {
      this.getReviewDetailData();
    },
    computed: {},
    methods: {
      getReviewDetailData(){
        getReviewDetail(this.id).then(async response => {
          if (response.data.code == 0) {
            this.detaildata  = response.data.data;
            if(response.data.data && response.data.data.review){
              this.businessKey = this.detaildata.review.reviewId;
            }
            if(response.data.data && response.data.data.opinionDetailList){
              this.opinionDetailList =await response.data.data.opinionDetailList;
            }
            if(response.data.data && response.data.data.connectDetailList){
              this.connectDetailList =await response.data.data.connectDetailList;
            }
            if(response.data.data && response.data.data.hisList){
              this.myhisList = await response.data.data.hisList;
            }
          }
        });
      },
      transfor(taskKey){
        switch (taskKey) {
          case 'review_report':return '提交';break;
          case 'review_update':return '修改';break;
          case 'review_record':return '报备';break;
          case 'review_dept_check':return '发改初审';break;
          case 'review_gov_check':return '政府审核';break;
          case 'review_offline':return '线下流程';break;
          case 'review_congress_check':return '人大审批';break;
          case 'review_city_gov_check':return '政府审批';break;
          case 'review_city_congress_check':return '人大审议';break;
          case 'review_province_gov_check':return '政府审批';break;
          case 'review_province_congress_check':return '人大审议';break;
        }
      },
      taskAssigneeHisView(taskAssigneeHisList){
        this.assignHisVisible = true;
        this.taskAssigneeHisList = taskAssigneeHisList
      },
      cancelAssignHis(){
        this.assignHisVisible = false;
      }
    }
  }
</script>

<style ang="scss" scoped>

</style>
